package com.sui.bigdata.rtcadmin.controller;



import com.sui.bigdata.rtcadmin.exception.SparkApplicationException;
import com.sui.bigdata.rtcadmin.model.dto.SparkAppDto;
import com.sui.bigdata.rtcadmin.model.vo.CommonResponse;
import com.sui.bigdata.rtcadmin.repository.mapper.AppConfMapper;
import com.sui.bigdata.rtcadmin.service.SparkAppConfService;
import com.sui.bigdata.rtcadmin.service.SparkAppService;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @Author: TingWuHuang
 * @Date: 2020/5/6 15:30
 * @description
 */
@RestController
@RequestMapping("spark")
public class SparkAppController {
    @Autowired
    SparkAppService sparkAppService;
    @Autowired
    SparkAppConfService sparkAppConfService;
    @Autowired
    AppConfMapper appConfMapper;


    @RequestMapping("isLive")
    public String isLive(){
        return "In service ...";
    }

    @PostMapping
    public CommonResponse action(@Param("action") String action, @RequestBody SparkAppDto sparkApp) throws SparkApplicationException {
        return sparkAppService.action(action, sparkApp);
    }

    @RequestMapping("save")
    public CommonResponse saveAppConfInfo(@RequestBody SparkAppDto sparkApp){
        return sparkAppConfService.saveAppConfInfo(sparkApp);
    }

    @RequestMapping("update")
    public CommonResponse updateAppConfInfo(@RequestBody SparkAppDto sparkApp){
        return sparkAppConfService.updateAppConfInfo(sparkApp);
    }

    @RequestMapping("query")
    public CommonResponse queryAllAppConfInfo(@RequestBody SparkAppDto sparkApp){
        return sparkAppConfService.selectSparkConf(sparkApp);
    }








}
